package com.example.beautymakeup.service.impl;

import com.example.beautymakeup.dao.InformationDao;
import com.example.beautymakeup.pojo.Information;
import com.example.beautymakeup.service.InformationService;
import com.example.beautymakeup.utils.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InformationServiceImpl implements InformationService {

    @Autowired
    private InformationDao informationDao;
    @Override
    public Information get() throws Exception {
        return informationDao.get();
    }

    @Override
    public boolean update(String token, Information information) throws Exception {
        String subject = JwtUtil.parseJWT(token).getSubject();
        if ("admin".equals(subject)){
            return informationDao.update(information) == 1;
        }else{
            return false;
        }
    }
}
